<?php

namespace App\Http\Resources\CruiseCheck\Merchant;

use App\Http\Resources\BaseResource;
use App\Models\Cruise\CruiseCheckSelfTaskModel;
use Illuminate\Http\Request;

class ShopSelfCheckListResource extends BaseResource
{

    /**
     * @param Request $request
     * @return array
     */
    public function toArray($request): array
    {
        list($state, $stateText) = CruiseCheckSelfTaskModel::transStatus($this->resource);

        return [
            "id"                => $this->id,
            "templateType"      => $this->templateType,
            "name"              => $this->name,
            "rule"              => $this->rule,
            "ruleText"          => CruiseCheckSelfTaskModel::RULE_TEXT[$this->rule] ?? "",
            "taskStartTime"     => $this->taskStartTime,
            "taskStartTimeText" => date("Y-m-d", $this->taskStartTime),
            "taskEndTime"       => $this->taskEndTime,
            "taskEndTimeText"   => date("Y-m-d", $this->taskEndTime),
            "executeStartHis"   => $this->executeStartHis,
            "executeEndHis"     => $this->executeEndHis,
            "templateId"        => $this->templateId,
            "totalCount"        => $this->totalCount,
            "invalidCount"      => $this->invalidCount,
            "finishCount"       => $this->finishCount,
            "state"             => $state,
            "stateText"         => $stateText,
        ];
    }
}
